package com.gmp.thewizard;

import android.graphics.PointF;
import android.util.Log;

public class State {
	
	public float width;
	public float height;
	public PointF collision;
	public PointRadius avatarspec;
	// space needed per obj: x/2 - r - r - x/2, where r is the radius and x the separation distance
	// x = 30 because r = 25 => 50 diameter, and r*2+30 = 80. 480 / 80 = 6.
	// hence, ...
	public Obstacle[] obspos;
	public Path path;
	private static final String TAG = "State";
	
	public State(){
		if(GameActivity.DEBUG) Log.d(TAG, "Creating initial avatar");
		this.avatarspec = new PointRadius(240, 765, 30);
		this.collision = new PointF();
		this.initialObstacle();
		this.initialPath();	
		Log.v(TAG, "State object created");
	}
	
	private void initialPath(){
		if(GameActivity.DEBUG) Log.d(TAG, "Creating initial path");
		this.path = new Path();
		this.path.add((int)this.avatarspec.x, 800);
		this.path.add(480, 400);
		this.path.add(240, 500);
		this.path.add(0, 0);
		this.path.close();
	}
	
	private void initialObstacle(){
		if(GameActivity.DEBUG) Log.d(TAG, "Creating initial path");
		this.obspos = new Obstacle[]{
				new Obstacle(40, 40, 25),
				new Obstacle(120, 40, 25),
				new Obstacle(200, 40, 25),
				new Obstacle(280, 40, 25),
				new Obstacle(360, 40, 25),
				new Obstacle(440, 40, 25)
		};
	}
	
	protected void setScreenSize(float width, float height){
		this.height = height;
		this.width = width;
	}
	
	protected void setAvatarSpec(PointRadius avatarspec){
		this.avatarspec = avatarspec;
	}
	
	protected void setAvatarPos(float x, float y){
		this.avatarspec.x = x;
		this.avatarspec.y = y;
	}
}
